<?php

Route::group(['middleware' => 'web', 'prefix' => 'admin', 'namespace' => 'Modules\Admin\Http\Controllers'], function()
{
    Auth::routes();
});

Route::group(['middleware' => ['web','auth:admin'], 'prefix' => 'admin', 'namespace' => 'Modules\Admin\Http\Controllers'], function()
{
    Route::get('/', 'AdminController@index');
    //用户资源控制器
    Route::resource('/adminuser', 'AdminUserController')->middleware('permission:admin,resource');
    //角色资源控制器
    Route::resource('/role','RoleController')->middleware('permission:admin,resource');
    //权限展示模板
    Route::get('/showPermission/{roleid}','RoleController@showPermission')->name('showPermission')->middleware('permission:admin');
    //处理权限
    Route::post('/permission/{roleid}','RoleController@permission')->name('permission');
//    用户分配角色加载模板路由
    Route::get('/showRole/{adminid}','AdminUserController@showRole')->name('showRole')->middleware('permission:admin');
    Route::post('/assignRole/{adminid}','AdminUserController@assignRole')->name('assignRole');
    //显示所有模块路由
    Route::get('/modules','ModulesController@index')->name('modulesList');
    //更新模块缓存路由
    Route::get('/refresh','ModulesController@refresh')->name('refresh');
    //设为默认模块路由
    Route::get('/setdefault/{modules}','ModulesController@setdefault')->name('setdefault');
    //后台模板列表路由
    Route::get('/template','TemplateController@index')->name('template');
    //设置默认模板路由
    Route::get('/setDefaultTemplate/{name}','TemplateController@setDefaultTemplate')->name('setDefaultTemplate');
});

